//
//  VsitorCommentCell.m
//  TravelFollowYourHeart
//
//  Created by ENERGY on 2018/1/9.
//  Copyright © 2018年 Lwx. All rights reserved.
//

#import "VsitorCommentCell.h"

@interface VsitorCommentCell()
@property (nonatomic, strong)UIImageView * iconImage;
@property (nonatomic, strong)UILabel * nameLab;
@property (nonatomic, strong)UILabel * dateLab;
@property (nonatomic, strong)UILabel * contentLab;
@property (nonatomic, strong)UIView * lineView;
@property (nonatomic, assign)NSString * mid;
@end

@implementation VsitorCommentCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self) {
        self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
//        self.contentView.backgroundColor = [UIColor yellowColor];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self.contentView addSubview:self.iconImage];
        [self.contentView addSubview:self.nameLab];
        [self.contentView addSubview:self.dateLab];
        [self.contentView addSubview:self.contentLab];
        
    }return self;
}

- (UIImageView *)iconImage{
    if (!_iconImage) {
        _iconImage = [[UIImageView alloc] init];
        _iconImage.image = [UIImage imageNamed:@"home_con_jwtx"];
//        _iconImage.backgroundColor = [UIColor orangeColor];
    }return _iconImage;
}

- (UILabel *)nameLab{
    if (!_nameLab) {
        _nameLab = [[UILabel alloc] init];
        _nameLab.text = @"XXXXXX";
        _nameLab.font = DEF_FontSize_14;
        _nameLab.textAlignment = NSTextAlignmentLeft;
        _nameLab.textColor = [UIColor blackColor];
//        _nameLab.backgroundColor = [UIColor greenColor];
    }return _nameLab;
}

- (UILabel *)dateLab{
    if (!_dateLab) {
        _dateLab = [[UILabel alloc] init];
        _dateLab.text = @"2000年00月00日";
        _dateLab.font = DEF_FontSize_12;
        _dateLab.textAlignment = NSTextAlignmentLeft;
        _dateLab.textColor = [UIColor grayColor];
//        _dateLab.backgroundColor = [UIColor orangeColor];
    }return _dateLab;
}

- (UILabel *)contentLab{
    if (!_contentLab) {
        _contentLab = [[UILabel alloc] init];
        _contentLab.text = @"XXXXXXXXXXXXXX";
        _contentLab.font = DEF_FontSize_10;
        _contentLab.textAlignment = NSTextAlignmentLeft;
        _contentLab.textColor = [UIColor grayColor];
    }return _contentLab;
}

- (UIView *)lineView{
    if (!_lineView) {
        _lineView = [[UIView alloc]init];
        _lineView.backgroundColor = [UIColor grayColor];
    }return _lineView;
}

- (void)layoutSubviews{
    [super layoutSubviews];
    CGFloat border = 10;
    CGFloat iconImageW = 30;
    CGFloat nameLabW = 100;
    CGFloat nameLabH = 15;
    CGFloat dateLabW = 200;
    self.iconImage.frame = CGRectMake(border, border, iconImageW, iconImageW);
    self.nameLab.frame = CGRectMake(self.iconImage.right + 5, self.iconImage.top, nameLabW, nameLabH);
    self.dateLab.frame = CGRectMake(self.nameLab.left, self.nameLab.bottom, dateLabW, nameLabH);
    self.iconImage.centerY = self.nameLab.bottom;
#warning 后期修改label高度
    self.contentLab.frame = CGRectMake(border, self.dateLab.bottom, SCREEN_WIDTH - 2 * border, 20);
    self.lineView.frame = CGRectMake(0, self.contentView.bottom, SCREEN_WIDTH, 1);
    self.mid = nil;
}

//- (void)setModelData:(VisitorCommentModelData *)modelData{
//    _modelData = modelData;
//    [self.iconImage sd_setImageWithURL:[NSURL URLWithString:self.modelData.avatar]];
//    self.nameLab.text = self.modelData.nickname;
//    self.dateLab.text = self.modelData.addtime;
//    self.contentLab.text = self.modelData.content;
//    self.mid = self.modelData.mid;
//}

- (void)setCellModelData:(VisitorCommentCellModelData *)cellModelData{
    _cellModelData = cellModelData;
    self.nameLab.text = self.cellModelData.nickname;
    self.dateLab.text = self.cellModelData.addtime;
    self.contentLab.text = self.cellModelData.content;
    self.mid = self.cellModelData.commentID;
    [self.iconImage sd_setImageWithURL:[NSURL URLWithString:self.cellModelData.avatar] placeholderImage:[UIImage imageNamed:@"home_con_jwtx"]];
}

- (void)setModelData:(VisitorCommentModelData *)modelData{
    _modelData = modelData;
    self.nameLab.text = self.modelData.nickname;
    self.dateLab.text = self.modelData.addtime;
    self.contentLab.text = self.modelData.content;
    self.mid = self.modelData.mid;
    [self.iconImage sd_setImageWithURL:[NSURL URLWithString:self.modelData.avatar] placeholderImage:[UIImage imageNamed:@"home_con_jwtx"]];
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
